<?php $this->_extends('_layouts/main_layout'); ?>

<?php $this->_block('title'); ?>
<?php
if (!empty($_SESSION['ga_title_full_reg']))
{
	echo $_SESSION['ga_title_full_reg'];
	unset($_SESSION['ga_title_full_reg']);
}
else
{
	echo 'Update Your Profile';
}
?>
<?php $this->_endblock(); ?>

<?php $this->_block('keywords');?>
<meta name="keywords" content="<?php echo $site['keywords']; ?>" />
<?php $this->_endblock();?>

<?php $this->_block('description');?>
<meta name="description" content="<?php echo $site['description']; ?>" />
<?php $this->_endblock();?>

<?php $this->_block('content'); ?>
<div class="mt">
	<?php $this->_element('social'); ?>
</div>
<div class="mm help">
	<div class="topad">
		<?php echo str_replace('[[USER_ID]]', $user['id'], $site['ad_top']);?>
	</div>
	<div class="clear" style="height: 10px"></div>
	<div class="left white">
		<div class="title">Update Your Profile</div>
		<h3>Please provide a valid address and phone number so that we can send your prize.</h3>
		<form action="<?php echo url('user/profiling'); ?>" method="post">
			<ul class="errors">
			<?php 
				if(isset($errors))
				{
					foreach ($errors as $error)
					{
						echo "<li>$error</li>";
					}
				}
			?>
			</ul>	
			<ul class="infos">
			<?php 
				if(isset($infos))
				{
					foreach ($infos as $info)
					{
						echo "<li>$info</li>";
					}
				}
			?>
			</ul>				
			<div class="left">
				<div class="tr">
					<div class="lable left">Gender</div>
					<div class="m left">
						<select name="gender">
							<option value="M" <?php echo isset($accountinfo['gender']) && $accountinfo['gender'] == 'M' ? 'selected="selected"' : '' ?>>Mr.</option>
							<option value="F" <?php echo isset($accountinfo['gender']) && $accountinfo['gender'] == 'F' ? 'selected="selected"' : '' ?>>Ms.</option>
						</select>
					</div>
					<div class="clear"></div>
				</div>
				<div class="tr">
					<div class="lable left">First Name</div>
					<div class="m left">
						<input class="inputtxt" name="firstname" id="firstname" value="<?php echo isset($accountinfo['firstname']) ? $accountinfo['firstname'] : ''; ?>"/>
					</div>
					<div class="clear"></div>
				</div>
				<div class="tr">
					<div class="lable left">Last Name</div>
					<div class="m left">
						<input class="inputtxt" name="lastname" id="lastname" value="<?php echo isset($accountinfo['lastname']) ? $accountinfo['lastname'] : ''; ?>"/>
					</div>
					<div class="clear"></div>
				</div>
				<div class="tr">
					<div class="lable left">Address</div>
					<div class="m left">
						<input class="inputtxt" type="text" name="address1" id="address" value="<?php echo isset($accountinfo['address1']) ? $accountinfo['address1'] : ''; ?>" />
					</div>
					<div class="clear"></div>
				</div>
				<div class="tr">
					<div class="lable left">Address 2</div>
					<div class="m left">
						<input class="inputtxt" type="text" name="address2" id="address2" value="<?php echo isset($accountinfo['address2']) ? $accountinfo['address2'] : ''; ?>" />
					</div>
					<div class="clear"></div>
				</div>
				<div class="tr">
					<div class="lable left">City</div>
					<div class="m left">
						<input class="inputtxt" type="text" name="city" id="city" value="<?php echo isset($accountinfo['city']) ? $accountinfo['city'] : ''; ?>" />
					</div>
					<div class="clear"></div>
				</div>
				<div class="tr">
					<div class="lable left">State</div>
					<div class="m left">
						<select id="state" class="" name="state">
						<?php 
						
							$states = array(
								'AL' => 'Alabama',
								'AK' => 'Alaska',
								'AR' => 'Arkansas',
								'AZ' => 'Arizona',
								'CA' => 'California',
								'CO' => 'Colorado',
								'CT' => 'Connecticut',
								'DE' => 'Delaware',
								'DC' => 'District of Columbia',
								'FL' => 'Florida',
								'GA' => 'Georgia',
								'HI' => 'Hawaii',
								'ID' => 'Idaho',
								'IL' => 'Illinois',
								'IN' => 'Indiana',
								'IA' => 'Iowa',
								'KS' => 'Kansas',
								'KY' => 'Kentucky',
								'LA' => 'Louisiana',
								'ME' => 'Maine',
								'MD' => 'Maryland',
								'MA' => 'Massachusetts',
								'MI' => 'Michigan',
								'MN' => 'Minnesota',
								'MS' => 'Mississippi',
								'MO' => 'Missouri',
								'MT' => 'Montana',
								'NE' => 'Nebraska',
								'NV' => 'Nevada',
								'NH' => 'New Hampshire',
								'NJ' => 'New Jersey',
								'NM' => 'New Mexico',
								'NY' => 'New York',
								'NC' => 'North Carolina',
								'ND' => 'North Dakota',
								'OH' => 'Ohio',
								'OK' => 'Oklahoma',
								'OR' => 'Oregon',
								'PA' => 'Pennsylvania',
								'RI' => 'Rhode Island',
								'SC' => 'South Carolina',
								'SD' => 'South Dakota',
								'TN' => 'Tennessee',
								'TX' => 'Texas',
								'UT' => 'Utah',
								'VA' => 'Virginia',
								'VT' => 'Vermont',
								'WA' => 'Washington',
								'WV' => 'West Virginia',
								'WI' => 'Wisconsin',
								'WY' => 'Wyoming',
							);
							
							foreach ($states as $k => $v) :
						?>
							<option value="<?php echo $k;?>" <?php echo (isset($accountinfo['state']) 
									&& $accountinfo['state'] == $k) ? 'selected="selected"' : ''; ?>><?php echo $v;?></option>
						<?php endforeach;?>
						</select>
					</div>
					<div class="clear"></div>
				</div>
				<div class="tr">
					<div class="lable left">Zip</div>
					<div class="m left">
						<input class="inputtxt" type="text" name="zipcode" id="zipcode" value="<?php echo isset($accountinfo['zipcode']) ? $accountinfo['zipcode'] : ''; ?>"  maxlength="5"/>
					</div>
					<div class="error left">Invalid zip, eg:12345</div>
					<div class="clear"></div>
				</div>
				<div class="tr">
					<div class="lable left">Email</div>
					<div class="m left">
						<input class="inputtxt" name="email" id="email"
							value="<?php echo isset($accountinfo['email']) ? $accountinfo['email'] : ''; ?>" />
					</div>
					<div class="clear"></div>
				</div>
				<div class="tr">
					<div class="lable left">Phone</div>
					<div class="m left">
						<input class="inputphone" name="countryCode" id="countryCode" value="<?php echo isset($accountinfo['countryCode']) ? $accountinfo['countryCode'] : ''; ?>" maxlength="3"/>
						<input class="inputphone" name="areaCode" id="areaCode" value="<?php echo isset($accountinfo['areaCode']) ? $accountinfo['areaCode'] : ''; ?>" maxlength="3"/> 
						<input	class="inputphone" name="subscriberNumber" id="subscriberNumber" value="<?php echo isset($accountinfo['subscriberNumber']) ? $accountinfo['subscriberNumber'] : ''; ?>" maxlength="4"/>
					</div>
					<div class="error left">Invalid number, eg:(XXX) YYY - ZZZZ</div>
					<div class="clear"></div>
				</div>
				<div class="tr">
					<div class="lable left">Birthday</div>
					<div class="m left">
						<span class="month">
							<select id="month" class="" name="birthMonth">
								<option value=""  label="Month">Month</option>
								<option value="01" label="January" <?php echo (isset($accountinfo['birthMonth']) && $accountinfo['birthMonth'] == '01')? 'selected="selected"' : '';?>>January</option>
								<option value="02" label="February" <?php echo (isset($accountinfo['birthMonth']) && $accountinfo['birthMonth'] == '02')? 'selected="selected"' : '';?>>February</option>
								<option value="03" label="March" <?php echo (isset($accountinfo['birthMonth']) && $accountinfo['birthMonth'] == '03')? 'selected="selected"' : '';?>>March</option>
								<option value="04" label="April" <?php echo (isset($accountinfo['birthMonth']) && $accountinfo['birthMonth'] == '04')? 'selected="selected"' : '';?>>April</option>
								<option value="05" label="May" <?php echo (isset($accountinfo['birthMonth']) && $accountinfo['birthMonth'] == '05')? 'selected="selected"' : '';?>>May</option>
								<option value="06" label="June" <?php echo (isset($accountinfo['birthMonth']) && $accountinfo['birthMonth'] == '06')? 'selected="selected"' : '';?>>June</option>
								<option value="07" label="July" <?php echo (isset($accountinfo['birthMonth']) && $accountinfo['birthMonth'] == '07')? 'selected="selected"' : '';?>>July</option>
								<option value="08" label="August" <?php echo (isset($accountinfo['birthMonth']) && $accountinfo['birthMonth'] == '08')? 'selected="selected"' : '';?>>August</option>
								<option value="09" label="September" <?php echo (isset($accountinfo['birthMonth']) && $accountinfo['birthMonth'] == '09')? 'selected="selected"' : '';?>>September</option>
								<option value="10" label="October" <?php echo (isset($accountinfo['birthMonth']) && $accountinfo['birthMonth'] == '10')? 'selected="selected"' : '';?>>October</option>
								<option value="11" label="November" <?php echo (isset($accountinfo['birthMonth']) && $accountinfo['birthMonth'] == '11')? 'selected="selected"' : '';?>>November</option>
								<option value="12" label="December" <?php echo (isset($accountinfo['birthMonth']) && $accountinfo['birthMonth'] == '12')? 'selected="selected"' : '';?>>December</option>
							</select>
						</span>
						<span class="day">
							<select id="day" class="" name="birthDay">
								<option value="" selected="selected" label="Day">Day</option>
								<?php 
									$days = array(
											'01', '02', '03', '04', '05', '06', '07', '08', '09'
											,'10', '11', '12', '13', '14', '15', '16', '17', '18', '19'
											,'20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'
									);
									foreach ($days as $day):
									
										if($accountinfo['birthDay'] == $day):
								?>
											<option value="<?php echo $day?>" selected="selected"><?php echo $day?></option>
										<?php else: ?>
											<option value="<?php echo $day?>"><?php echo $day?></option>
								<?php 
									endif;
									endforeach;
								?>
								</select>
						</span>
						<span class="year">
							<select id="year" class="" name="birthYear">
								<option value="" selected="selected" label="Year">Year</option>
								<?php 
									for ($i = 1993; $i >= 1911 ; $i--) :
								?>
									<option value="<?php echo $i; ?>" <?php echo (isset($accountinfo['birthYear']) && intval($accountinfo['birthYear']) == $i) ? 'selected="selected"' : '';?>><?php echo $i;?></option>
								<?php endfor;?>
							</select>
						</span>
					</div>
					
					<div class="clear"></div>
				</div>
				
				
				
<!--			
				<?php if (empty($accountinfo['optin_sj']) || $accountinfo['optin_sj'] == '0') { ?>
 					<div class="tr" style="line-height:18px;">
						<div class="lable left" style="height:30px;"></div> 
						<div>
							<input type="checkbox" name="optin_sj" id="optin_sj" value="1" />
							<label for="optin_sj">Get Paid to Review products online for cash and rewards with ShoppingJobs.com, It’s free to Join!</label> 
							<div class="clear"></div>
						</div>
					</div>
				<?php } ?>
-->				
<!--				<?php if (empty($accountinfo['optin_inpays']) || $accountinfo['optin_inpays'] == '0') { ?>
 					<div class="tr" style="line-height:18px;">
						<div class="lable left" style="height:60px;"></div> 
						<div>
							<input type="checkbox" name="optin_inpays" id="optin_inpays" value="1" <?php echo isset($accountinfo['optin_inpays']) && $accountinfo['optin_inpays']=='1' ? 'checked="checked"' : '';?> />
							<label for="optin_inpays">Make cash with InboxPays. Get paid to evaluate products and services as well as participating in online surveys, clipping coupons, reading emails and playing cash games. Sign up for FREE today and get a $5.00 Bonus!</label> 
							<div class="clear"></div>
						</div>
					</div>
				<?php } ?>
-->
<!--				
				<?php if (empty($accountinfo['optin_greateamerican']) || $accountinfo['optin_greateamerican'] == '0') { ?>
 					<div class="tr" style="line-height:18px;">
						<div class="lable left" style="height:60px;"></div> 
						<div>
							<input type="checkbox" name="optin_greateamerican" id="optin_greateamerican" value="1" <?php echo isset($accountinfo['optin_greateamerican']) && $accountinfo['optin_greateamerican']=='1' ? 'checked="checked"' : '';?> />
							<label for="optin_greateamerican">Free stuff for you and your baby (or baby on the way)!  We will contact you by phone and email with free gifts, gift cards, new products to test, and other special opportunities. <a href="http://BabyFreebiePromos.com" target="_blank">BabyFreebiePromos.com/privacy</a></label> 
							<div class="clear"></div>
						</div>
					</div>
				<?php } ?>
-->				
				<?php if (empty($accountinfo['optin_edu']) || $accountinfo['optin_edu'] == '0') { ?>
		 			<div class="tr" style="line-height:18px;">
						<div class="lable left" style="height:40px;"></div> 
						<div>
							<input type="checkbox" name="optin_edu" id="optin_edu" value="1" />
							<label for="optin_edu">Sign up for Eversave Coupons & Savings today for email with FREE coupons and samples from top brand names plus recipes, sweepstakes and much more!</label> 
							<div class="clear"></div>
						</div>
					</div>
				<?php } ?>
				
				
				
				
				<div class="tr">
					<div class="lable left"></div>
					<div class="m left save">
						<input type="image"
							src="<?php echo $img_url;?>saveprofile.png" alt=""
									name="submit" width="208" height="51" id="submit"/>
					</div>
					<div class="clear"></div>
				</div>
			</div>
			<span class="left">
				<?php if(isset($user) && empty($user['address1'])): ?>
					<img alt="" src="<?php echo $img_url;?>clicktocomplete10_2.png" />
				<?php endif;?>
			</span>
		</form>
		
	</div>
	<div class="right rightad">
		<?php if (!empty($site['ad_right']))
				$this->_element('rightad');
		?>
	</div>
	<div class="clear" style="height: 20px;"></div>
	<div class="bottomad">
		<?php if (!empty($site['ad_bottom']))
					echo $site['ad_bottom'];
		?>
	</div>
</div>
<div class="mb"></div>
<script type="text/javascript">
	
	$(function(){
		$('#submit').click(function(){
			var reg=/^\d{5}$/;
			if(!reg.test($('#zipcode').val())){
				$('#zipcode').parent().next().show();
				return false;
			}
			reg=/^\d{3}-\d{3}-\d{4}$/;
			var phone = $('#countryCode').val() + '-' + $('#areaCode').val() + '-' + $('#subscriberNumber').val();
			if(!reg.test(phone)){
				$('#countryCode').parent().next().show();
				return false;
			}
			return true;
		});
		$('#zipcode').focus(function(){
				$(this).parent().next().hide();
			}
		);
		$('.inputphone').each(function(){
			$(this).focus(function(){
				$(this).parent().next().hide();
			});
		});
	});
	
</script>
<?php $this->_endblock(); ?>